package bibliotecas;
import java.awt.Graphics;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JImage extends JPanel{

	private static final long serialVersionUID = 5579096266467300254L;
	private BufferedImage image;

    public JImage(String imagem) {
    	this.addComponentListener(new ComponentAdapter() {
			@Override
			public void componentResized(ComponentEvent arg0) {
				repaint();
			}
		});
       try {                
          image = ImageIO.read(new File(imagem));
       } catch (IOException ex) {
    	   ex.printStackTrace();
       }
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.drawImage(image,0,0,this.getWidth(),this.getHeight(),null);
    }
    
    public void setDimensoes(int x,int y,int w,int h){
    	this.setBounds(x,y,w,h);
    }

}